<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<title>javascript事件的使用</title>
	</head>
	<body onload="doload()">
		<form action="" method="post">
			<input name="username" type="text" placeholder="请输入用户名" onchange="dochange(this)" />
			
			<input type="button" value="普通按钮" onclick="doclick()"/>
		</form>
		
		<div style="width: 100px; height: 100px; background-color: red;" onmouseover="over(this)" onmouseout="out(this)"></div>
		
		<script type="text/javascript">
			function dochange(obj){
				alert("内容变化了"+obj.value);
				//ajax请求
			}
			
			function doclick(){
				alert("点我干嘛?你再点下试试");
			}
			
			function over(obj){
				obj.style.backgroundColor="skyblue";
			}
			function out(obj){
				obj.style.backgroundColor="red";
			}

			function doload(){
				alert("页面已经加载完毕");
			}
		</script>
		
	</body>
</html>
